Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add authentication #118

Merged
merged 1 commit into from
Oct 31, 2023
Merged

add authentication #118

merged 1 commit into from
Oct 31, 2023

Conversation

LKSeng
Copy link
Contributor

@LKSeng LKSeng commented Aug 29, 2023

This is basically a port for the authenticate function in roslibjs. It enables the example in rosauth to be performed on roslibpy, as well as fixes #86.

Following the example in rosauth, one would call authenticate() before calling run():

import roslibpy

auth = {'mac' : '19d9d2166799f1ffd6fee6379f957502aff8716bfebc8cc8b3bac57ade14441bb9678be89d0a7eec9c81291f854d754d7a4de2278bede56f162c2faeb468c68a',
    'client' : 'client',
    'dest' : 'dest',
    'rand' : 'rand',
    't' : 0,
    'level' : 'level',
    'end' : 0
}

client = roslibpy.Ros(host='localhost', port=9090)
client.authenticate(**auth) # need for authentication is specified here. ** is used to unpack the dictionary.
client.run()

# subscriber example.
listener = roslibpy.Topic(client, '/chatter', 'std_msgs/String')
listener.subscribe(lambda message: print('Heard talking: ' + message['data']))

try:
    while True:
        pass
except KeyboardInterrupt:
    client.terminate()

On the rosbridge_server terminal one would see:

2023-08-29 13:55:43+0000 [-] [INFO] [1693317343.325643]: Client connected.  1 clients total.
2023-08-29 13:55:43+0000 [-] [INFO] [1693317343.326674]: Awaiting proper authentication...
2023-08-29 13:55:43+0000 [-] [INFO] [1693317343.329715]: Client 1 has authenticated.

I am unsure what tests and documentation to include for this change.

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.rst file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke check).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@gonzalocasas
Copy link
Member

Awesome! Thanks a lot!

Copy link
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gonzalocasas gonzalocasas merged commit ed088b6 into gramaziokohler:main Oct 31, 2023
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

authenticate-function
2 participants